<template>
	<view class="content">
		<view style="text-align: center;">AI<text>{{typeIndex==1?'故事':'诗词'}}</text>列表</view>
		<view class="con-top">
			<image src="../../static/icon/luzhi.png" style="width: 18px;height: 15px;"></image>
			<view>播放全部({{list.length}})</view>
			<view class="top-text">故事详情</view>
		</view>
		<view class="con-mid" v-if="list.length>0">
			<view v-for="(item,index) in  list" :key="index" class="mid-label"
				@click="goDetail(item.id,index)">
				{{index+1}} 故事:{{item.title}}
			</view>
		</view>
		<view v-else>
			<view class="con-btm">当前无内容</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: {},
				typeIndex: 1,
				option:{}
			};
		},
		onLoad(option) {
			console.log(option)
			if (option) {
				this.typeIndex = option.type
				this.option = option
			}
			if (option.type == 1) {
				let con = uni.getStorageSync('story')
				this.list = con.filter(x => x.id == option._id)[0].content
			} else if (option.type == 2) {
				this.list = [{
						id: 355,
						title: "长歌行",
						fileUrl: "https://nn-sycdn.kuwo.cn/a9724cfa8fe5bb3eac8544ad0df257e1/66ebcef2/resource/n1/63/74/1656919529.mp3"
					},
					{
						id: 466,
						title: "敕勒歌",
						fileUrl: "https://nm-sycdn.kuwo.cn/e500bc7622df9916715b816d3185a7a6/66ebcf1c/resource/n2/10/84/2125807569.mp3"
					},
					{
						id: 577,
						title: "静夜思",
						fileUrl: "https://nn-sycdn.kuwo.cn/8bbe009163501ef4190bb7af375150bf/66ebcfc3/resource/n2/72/96/3121895547.mp3"
					}
				]
				//存缓存
				uni.setStorageSync(
					"poem",
					this.list
				);
			}

		},
		methods: {
			goDetail(id) {
				uni.navigateTo({
					url: `/pages/story/detail?_id=${id}&storyId=${this.option._id}&type=${this.option.type}`
				});
			}
		}
	}
</script>

<style lang="scss" scoped>
	.content {

		padding: 70rpx 20rpx 30rpx 20rpx;

		.con-top {
			display: flex;
			align-items: center;
			font-size: 44rpx;
			margin: 50rpx 10px 0 10px;
			justify-content: space-around;

			image {
				margin: 0 15rpx 0 0;
			}

			.top-text {
				background-color: #ff0056;
				padding: 6rpx 20rpx;
				border-radius: 30rpx;
				font-size: 38rpx;
			}

		}

		.con-mid {
			margin: 0 10px 20px 10px;

			.mid-label {
				margin: 14rpx 0;
				overflow: hidden;
				text-overflow: ellipsis;
				white-space: nowrap;
			}
		}

		.con-btm {
			position: absolute;
			left: 50%;
			top: 50%;
			transform: translate(-50%, -50%);
			color: #93999c;
		}
	}
</style>